﻿using DevComponents.DotNetBar;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WorkStation.UI.Controls
{
    public partial class FormPoint : Office2007Form
    {
        private MotionCoordinate _x;
        private MotionCoordinate _y;
        private MotionCoordinate _r;
        public double X;
        public double Y;
        public double R;
        public FormPoint(MotionCoordinate crdX, MotionCoordinate crdY, MotionCoordinate crdR)
        {
            InitializeComponent();
            this.EnableGlass = false;

            _x = crdX;
            _y = crdY;
            _r = crdR;
        }

        private void FormPoint_Load(object sender, EventArgs e)
        {
            if (_x != null && _y != null)
            {
                l_AxisName1.Text = _x.Description;
                l_Unit1.Text = "mm";
                l_AxisName2.Text = _y.Description;
                l_Unit2.Text = "mm";
            }
            else if (_x != null)
            {
                l_AxisName1.Text = _x.Description;
                l_Unit1.Text = "mm";
                l_AxisName2.Visible = false;
                l_Unit2.Visible = false;
                dI_Axis2.Visible = false;
            }
            else if (_y != null)
            {
                l_AxisName1.Text = _y.Description;
                l_Unit1.Text = "mm";
                l_AxisName2.Visible = false;
                l_Unit2.Visible = false;
                dI_Axis2.Visible = false;
            }
            else if (_r != null)
            {
                l_AxisName1.Text = _r.Description;
                l_Unit1.Text = "°";
                l_AxisName2.Visible = false;
                l_Unit2.Visible = false;
                dI_Axis2.Visible = false;
            }
        }

        private void btn_Confirm_Click(object sender, EventArgs e)
        {
            if (_x != null && _y != null)
            {
                X = dI_Axis1.Value;
                Y = dI_Axis2.Value;
            }
            else if (_x != null)
            {
                X = dI_Axis1.Value;
            }
            else if (_y != null)
            {
                Y = dI_Axis1.Value;
            }
            else if (_r != null)
            {
                R = dI_Axis1.Value;
            }
            this.DialogResult = DialogResult.OK;
            this.Close();
        }

        private void btn_Cancel_Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.Cancel;
            this.Close();
        }
    }
}
